﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Reflection;

namespace WebTest.Infrastructure.Data
{
    public class OrderContext : DbContext
    {
        public OrderContext() : base() { }
        public OrderContext(DbContextOptions<OrderContext> options) : base(options) { }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            
            modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());

        }
        protected override void OnConfiguring(DbContextOptionsBuilder options)
        {
            options.UseMySql("Server=192.168.1.233;port=3306;database=test;uid=test01;pwd=test123456;pooling=true;CharSet=utf8mb4;SslMode=None");

            //options.UseMySql("Server=192.168.1.233;port=3306;database=test;uid=test01;pwd=test123456;pooling=true;CharSet=utf8mb4;SslMode=None", MySqlServerVersion.LatestSupportedServerVersion, mysqlOptions =>
            //{
            //    mysqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
            //});
        }
    }
}
